#ifndef PHYSICALOBJECT_H_
#define PHYSICALOBJECT_H_

#include <vector>
#include "Box2D\Box2D.h"
#include "Objects/GameObject.h"

using namespace std;

class PhysicalObject : public GameObject
{
public:
	PhysicalObject(GameState *gameState);
	~PhysicalObject();

	
	b2BodyDef* getBodyDef(){ return &m_bodyDef; }

	void setBodyDef(const b2BodyDef &bodyDef){ m_bodyDef = bodyDef; }

	b2Body* getBody(){ return m_body; }

	void setBody(b2Body *body){ m_body = body; }

	void addFixtureDef(b2FixtureDef *def);

	b2FixtureDef* getFixtureDef(int i);

	int getFixtureDefCount() { return m_fixtureDefs.size(); }

	void removeFixtureDef(int i);

	// Transformations
	virtual const b2Vec2& getPosition() const;

	virtual void setPosition(const b2Vec2 &position);

	virtual float getRotation() const;

	virtual void setRotation(float radians);

	// Rendering
	virtual void draw();

	void drawFixtures(bool fill = false);

	// Collisions
	virtual void beginContact(b2Contact *contact);

	virtual void endContact(b2Contact *contact);

	virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);

	virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);

	void getContactEntities(b2Contact *contact, PhysicalObject **me, PhysicalObject **other = NULL, b2Fixture **myFixture = NULL, b2Fixture **otherFixture = NULL);

protected:
	b2Body *m_body;   // This body must be allocated by the b2World

private:
	b2BodyDef m_bodyDef;

	vector<b2FixtureDef*> m_fixtureDefs;

};

#endif
